package pw.goyd.game.handler.imp;

import pw.goyd.game.handler.Handler;
import pw.goyd.game.logic.BetRequest;
import pw.goyd.game.server.Log;
import pw.goyd.game.server.LoginList;
import pw.goyd.subscribe.PlayerCustomer;

public class BET extends Handler {
    /**
     * 下注
     */
    @Override
    public void handle() {
        // 读设定下注倍数
        BetRequest betRequest = new BetRequest();
        betRequest.readFromBytes(request.getData());
        int bet = betRequest.getBet();
        // 设置抢庄分数
        PlayerCustomer betPlayer = LoginList.getPlayer(ctx.getChannel().getId());
        if (betPlayer != null) {
            betPlayer.setBet(bet);
            betPlayer.sendBet();    // 推送到房间
        } else {
            Log.getLogger().error("空指针--->ChannelID[" + ctx.getChannel().getId() + "]");
        }

    }

}
